I have decided to design a the Input and Output circut in one board. I chosed the Ultrasonic Sensor "HC-SR04" as Input to be used in measuring the distance and "RGB Led" as Output for emmiting beautiful colors.
First I started form Niel's boards hello.HC-SR04 and hello.RGB.45 , and I used Eagle to combine them
This week I am focusing on the Input part. First I connected the Ultrasonic sensor to the board using four jumper wires and a breadboard then I used Arduno sketch to write program that calculate the distance, and print it on the screen
#include < SoftwareSerial.h > SoftwareSerial mySerial (0,2); int trig = 3; int echo = 4; long duration, distance ; void setup() { mySerial.begin(9600); pinMode(trig, OUTPUT); pinMode(echo, INPUT); } void loop() { digitalWrite(trig, LOW); delayMicroseconds(2); digitalWrite(trig, HIGH); delayMicroseconds(10); digitalWrite(trig, LOW); duration = pulseIn(echo,HIGH); distance = duration / 58; mySerial.print("The Distance is: "); mySerial.println(distance); delay(100); }
This work by Joseph Gourgy is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.